{# The Secrets and Settings pages' shared pieces, imported with context (``writable``, ``store``): where values live, the tables by owner, and a row's name, value and actions. A row may name its own Set label (``set_label``). Three columns, so a long description wraps under its name rather than pushing the row's actions out of the card. #} {% from "components/macros/form.html" import action %} {% from "components/macros/layout.html" import badge, card %} {% from "components/macros/table.html" import data_table %} {% macro name_cell(named) -%} {{ named.name }} {%- if named.label %}

{{ named.label }}

{% endif %} {%- endmacro %} {% macro value_cell(shown) -%} {{ shown.text }}

{{ badge(shown.source.label, shown.source.tone) }} {%- if shown.default %}default {{ shown.default }}{% endif %} {%- if shown.when %}{{ shown.when }}{% endif %}

{%- endmacro %} {% macro row_actions(row) -%} {%- if row.testable -%} {{ action("Test", 'hx-post="' ~ row.url ~ '/test" hx-swap="none"') }} {%- endif -%} {%- if row.editable -%} {{ action(row.set_label or ("Set" if row.shown.missing else "Replace"), hx_dialog(row.url), "primary" if row.shown.missing else "default") }} {%- elif row.in_env and writable -%} Change it in .env {%- elif row.env_only -%} Set it in .env {%- endif -%} {%- endmacro %} {% macro backend_note(page, saved, verb) -%}

{% if writable %}{{ saved }} A value set in .env still wins. {% elif store %}Values are managed in {{ store }}: change them there. A value set in .env still wins. {% else %}Values come from .env and the process environment, and change when the server restarts. Add the secrets component to {{ verb }} them here instead.{% endif %}

{%- endmacro %} {% macro owner_tables(page, groups) -%} {% set columns = [ {"key": "named", "label": "Name", "render": name_cell, "wrap": True}, {"key": "shown", "label": "Value", "render": value_cell}, ] %} {% for group in groups %} {% call card(None, id=page ~ "-" ~ loop.index) %}

{{ group.owner }}

{{ data_table(columns, group.rows, actions=row_actions) }} {% endcall %} {% endfor %} {%- endmacro %}